#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>

using namespace std;

cv::VideoCapture gCap;
cv::Mat img_rgb, img_pyrDown;
int gCurrentPos;
int pyrDownMaxLevel = 4;
//滑动条的回调函数
void onTrackbarSlide(int pos, void *)
{
    for (int i=0; i<pos; i++)
    {
        //降采样
        cv::pyrDown(img_rgb, img_pyrDown);
    }
//    gCap.set(cv::CAP_PROP_POS_FRAMES, pos);
}

int main()
{
    cv::namedWindow("img_rgb", cv::WINDOW_AUTOSIZE);
    cv::namedWindow("img_pyrDown", cv::WINDOW_AUTOSIZE);
    //创建滑动条
    cv::createTrackbar("pyrDownSlide", "img_rgb", &gCurrentPos, pyrDownMaxLevel, onTrackbarSlide);
    //打开视频
    gCap.open("../../resource/video/test_for_car.mp4");
    for (;;)
    {
        gCap >> img_rgb;
        if (img_rgb.empty())
            break;
        cv::imshow("img_rgb", img_rgb);
        cv::pyrDown(img_rgb, img_pyrDown);
        cv::imshow("img_pyrDown", img_pyrDown);
        if (cv::waitKey(33) >= 0)
            break;
    }

    return 0;
}
